package com.starmark.sys.login.api.dto;

import lombok.Data;
import lombok.EqualsAndHashCode;

import java.io.Serializable;

/**
 * 默认用户登陆Token
 */
@Data
@EqualsAndHashCode(callSuper = true)
public class UserLoginToken extends LoginDto implements Serializable {

    /**
     * 登陆类型
     */
    private String loginType;

    private UserLoginToken() {
        super();
    }

    public UserLoginToken(final String username, final String password) {
        super(username, password);
    }

    /**
     * 是否需要密码校验
     */
    private boolean requriedPassword;


    public static UserLoginToken buildNoPassword(String username, String loginType) {
        UserLoginToken userLoginToken = new UserLoginToken(username,null);
        userLoginToken.setLoginType(loginType);
        userLoginToken.setRequriedPassword(false);
        return userLoginToken;
    }

    public static UserLoginToken buildPassword(String username, String password, String loginType) {
        UserLoginToken userLoginToken = new UserLoginToken(username, password);
        userLoginToken.setLoginType(loginType);
        userLoginToken.setRequriedPassword(true);
        return userLoginToken;
    }


}
